﻿using ConfExpert.Forms.Base;
using DevExpress.XtraEditors;
using DevTeam;
using System;
using System.Data;

namespace ConfExpert.Forms.Lojistik
{
    public partial class GP_7C_Tip2 : XForm
    {
        public GP_7C_Tip2()
        {
            InitializeComponent();
        }

        private void GP_7C_Tip2_Load(object sender, EventArgs e)
        {
            this.Text = "7C Barkod Dosyası";
            DataSet ds = ExecuteDataSet("GetGPSiparis_Direct2");
            gridView1.Init(ds.Tables[0]);
            gridView2.Init(ds.Tables[1]);
            gridView1.SetToolTip("Adet:Adet Toplam");
            gridView1.MakeReadOnly();
            gridView2.MakeReadOnly();
            gridView2.MakeColumnInvisible("M", "T");

            string Modellos = gridView1.GetSelectedValues("Modello").Replace(",", "','");
            string Tessutos = gridView1.GetSelectedValues("Tessuto").Replace(",", "','");
            gridView2.ActiveFilterString = "M in ('" + Modellos + "') AND T in ('" + Tessutos + "')";
            gridView2.BestFitColumns();

            gridView1.SelectionChanged += gridView1_SelectionChanged;
            btnExport.ItemClick += btnExport_ItemClick;
            btnOzet.ItemClick += btnOzet_ItemClick;
            gridView1.BestFitColumns();
            gridView2.BestFitColumns();
        }

        void btnOzet_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            XtraMessageBox.Show("Hazırlanacak", "Uyarı");
        }

        void btnExport_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            gridView1.EndEditing();
            gridView2.EndEditing();

            gridView2.ExportToExcel();
        }

        void gridView1_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e)
        {
            string Modellos = gridView1.GetSelectedValues("Modello").Replace(",", "','");
            string Tessutos = gridView1.GetSelectedValues("Tessuto").Replace(",", "','");
            gridView2.ActiveFilterString = "M in ('" + Modellos + "') AND T in ('" + Tessutos + "')";
            gridView2.BestFitColumns();
        }
    }
}
